package cn.cherry.utils;

import lombok.Data;

/**
 * @Author: SongTiankai
 * @Description: 统一返回类
 * @Date: 2023/12/31 20:53
 * @Version: 1.0
 */
@Data
public class ResponseData {

    private boolean sucess;

    private Integer code;

    private String  msg;

    private Object data;


    public ResponseData(boolean sucess, Integer code, String msg, Object data) {
        this.sucess = sucess;
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    /**
     * 成功返回
     * @param data
     * @return
     */
    public static ResponseData ok(Object data){
        ResponseData sucessData = new ResponseData(true, 200, "ok", data);
        return sucessData;
    }

    /**
     * 失败返回
     * @param code
     * @param msg
     * @return
     */
    public static ResponseData error(Integer code,String msg){
        ResponseData errorData = new ResponseData(false, code, msg, null);
        return errorData;
    }

    /**
     * 自定义数据结构
     * @return
     */
    public static ResponseData build(Object data){
        return null;
    }
}
